<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:materialConverters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="../Brushes/MaterialDesign/MaterialDesignTheme.Theme.xaml"/>
    <ResourceDictionary Source="MaterialDesignTheme.Button.xaml" />
  </ResourceDictionary.MergedDictionaries>

  <materialConverters:MathConverter Operation="Divide" x:Key="DivisionMathConverter"/>

  <Style x:Key="MaterialDesignScrollBarButton" TargetType="{x:Type RepeatButton}">
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignSelection}" />
    <Setter Property="Background" Value="{DynamicResource MaterialDesignSelection}" />
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Padding" Value="1"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RepeatButton}">
          <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
            <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Background" Value="{DynamicResource MaterialDesignDivider}"/>
              <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignDivider}"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="true">
              <Setter Property="Background" Value="{DynamicResource MaterialDesignDivider}"/>
              <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignDivider}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Opacity" TargetName="contentPresenter" Value="{StaticResource DisabledOpacity}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignRepeatButtonTransparent" TargetType="{x:Type RepeatButton}">
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Focusable" Value="false"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RepeatButton}">
          <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignScrollBarThumbVertical" TargetType="{x:Type Thumb}">
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Thumb}">
          <Border CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}" Background="{TemplateBinding Foreground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" SnapsToDevicePixels="True" Opacity="0.6">
            <!--<Rectangle x:Name="rectangle" Fill="{TemplateBinding Foreground}" Height="{TemplateBinding Height}" SnapsToDevicePixels="True" Width="{TemplateBinding Width}" Visibility="Collapsed"/>-->
          </Border>
          <!--<ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource MaterialDesignDivider}"/>
            </Trigger>
            <Trigger Property="IsDragging" Value="true">
              <Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource MaterialDesignDivider}"/>
            </Trigger>
          </ControlTemplate.Triggers>-->
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignScrollBarThumbHorizontal" TargetType="{x:Type Thumb}">
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="IsTabStop" Value="false"/>
    <Setter Property="Opacity" Value="0.6"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Thumb}">
          <Border CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualHeight, Converter={StaticResource DivisionMathConverter}, ConverterParameter=2.0}" Background="{TemplateBinding Foreground}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
            <!--<Rectangle x:Name="rectangle" Fill="{TemplateBinding Foreground}" Height="{TemplateBinding Height}" SnapsToDevicePixels="True" Width="{TemplateBinding Width}" Visibility="Collapsed"/>-->
          </Border>
          <!--<ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource MaterialDesignDivider}"/>
            </Trigger>
            <Trigger Property="IsDragging" Value="true">
              <Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource MaterialDesignDivider}"/>
            </Trigger>
          </ControlTemplate.Triggers>-->
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignScrollBar" TargetType="{x:Type ScrollBar}">
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
    <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="BorderBrush" Value="Transparent"/>
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
    <Setter Property="BorderThickness" Value="1,0"/>
    <Setter Property="Width" Value="12"/>
    <Setter Property="MinWidth" Value="12"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ScrollBar}">
          <Grid x:Name="Bg" SnapsToDevicePixels="true">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CommonStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="*" To="MouseOver">
                    <Storyboard FillBehavior="HoldEnd">
                      <DoubleAnimation Storyboard.TargetName="PART_Track" Storyboard.TargetProperty="Width" To="10" Duration="0:00:0.15" />
                      <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Width" To="10" Duration="0:00:0.15" />
                      <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Opacity" To="0.9" Duration="0:00:0.15" />
                    </Storyboard>
                  </VisualTransition>
                  <VisualTransition From="MouseOver" To="Normal">
                    <Storyboard FillBehavior="HoldEnd">
                      <DoubleAnimation Storyboard.TargetName="PART_Track" Storyboard.TargetProperty="Width" To="4" Duration="0:00:0.15" />
                      <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Width" To="4" Duration="0:00:0.15" />
                      <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0:00:0.15" />
                    </Storyboard>
                  </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Normal">
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="PART_Track" Storyboard.TargetProperty="Width" To="4" Duration="0:00:0.15" />
                    <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Width" To="4" Duration="0:00:0.15" />
                    <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0:00:0.15" />
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="MouseOver">
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="PART_Track" Storyboard.TargetProperty="Width" To="10" Duration="0:00:0.15" />
                    <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Width" To="10" Duration="0:00:0.15" />
                    <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Opacity" To="0.9" Duration="0:00:0.15" />
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
            <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}" Width="4">
              <Track.DecreaseRepeatButton>
                <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource MaterialDesignRepeatButtonTransparent}"/>
              </Track.DecreaseRepeatButton>
              <Track.IncreaseRepeatButton>
                <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource MaterialDesignRepeatButtonTransparent}"/>
              </Track.IncreaseRepeatButton>
              <Track.Thumb>
                <Thumb Name="TrackThumb" Style="{StaticResource MaterialDesignScrollBarThumbVertical}" HorizontalAlignment="Right" Width="4"/>
              </Track.Thumb>
            </Track>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Opacity" Value="{StaticResource DisabledOpacity}"/>
      </Trigger>
      <Trigger Property="Orientation" Value="Horizontal">
        <Setter Property="Width" Value="Auto"/>
        <Setter Property="MinWidth" Value="0"/>
        <Setter Property="Height" Value="12"/>
        <Setter Property="MinHeight" Value="12"/>
        <Setter Property="BorderThickness" Value="0,1"/>
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type ScrollBar}">
              <Grid x:Name="Bg" SnapsToDevicePixels="true">
                <VisualStateManager.VisualStateGroups>
                  <VisualStateGroup x:Name="CommonStates">
                    <VisualStateGroup.Transitions>
                      <VisualTransition From="*" To="MouseOver">
                        <Storyboard FillBehavior="HoldEnd">
                          <DoubleAnimation Storyboard.TargetName="PART_Track" Storyboard.TargetProperty="Height" To="10" Duration="0:00:0.15" />
                          <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Height" To="10" Duration="0:00:0.15" />
                          <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Opacity" To="0.9" Duration="0:00:0.15" />
                        </Storyboard>
                      </VisualTransition>
                      <VisualTransition From="MouseOver" To="Normal">
                        <Storyboard FillBehavior="HoldEnd">
                          <DoubleAnimation Storyboard.TargetName="PART_Track" Storyboard.TargetProperty="Height" To="4" Duration="0:00:0.15" />
                          <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Height" To="4" Duration="0:00:0.15" />
                          <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0:00:0.15" />
                        </Storyboard>
                      </VisualTransition>
                    </VisualStateGroup.Transitions>
                    <VisualState x:Name="Normal">
                      <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="PART_Track" Storyboard.TargetProperty="Height" To="4" Duration="0:00:0.15" />
                        <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Height" To="4" Duration="0:00:0.15" />
                        <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Opacity" To="0.6" Duration="0:00:0.15" />
                      </Storyboard>
                    </VisualState>
                    <VisualState x:Name="MouseOver">
                      <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="PART_Track" Storyboard.TargetProperty="Height" To="10" Duration="0:00:0.15" />
                        <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Height" To="10" Duration="0:00:0.15" />
                        <DoubleAnimation Storyboard.TargetName="TrackThumb" Storyboard.TargetProperty="Opacity" To="0.9" Duration="0:00:0.15" />
                      </Storyboard>
                    </VisualState>
                  </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
                <Track x:Name="PART_Track" Grid.Column="1" IsEnabled="{TemplateBinding IsMouseOver}" Height="4">
                  <Track.DecreaseRepeatButton>
                    <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource MaterialDesignRepeatButtonTransparent}"/>
                  </Track.DecreaseRepeatButton>
                  <Track.IncreaseRepeatButton>
                    <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource MaterialDesignRepeatButtonTransparent}"/>
                  </Track.IncreaseRepeatButton>
                  <Track.Thumb>
                    <Thumb Name="TrackThumb" Style="{StaticResource MaterialDesignScrollBarThumbHorizontal}" VerticalAlignment="Bottom" Height="4"/>
                  </Track.Thumb>
                </Track>
              </Grid>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Trigger>
    </Style.Triggers>
  </Style>

  <Style x:Key="{x:Type ScrollBar}" BasedOn="{StaticResource MaterialDesignScrollBar}" TargetType="{x:Type ScrollBar}" />

</ResourceDictionary>
